#include "qpropertyview.h"

#include "../../libs/corelib/qpropertylistview.h"
#include "../../libs/sharedlib/qabstracthost.h"
#include "../../libs/corelib/styledbar.h"


#include <QVBoxLayout>
#include <QLabel>

QPropertyView::QPropertyView(QWidget *parent) :
    QWidget(parent),
    m_propertyView(new CORELIB::QPropertyListView(this)),
    m_styledBar(new CORELIB::StyledBar(this))
{
    QVBoxLayout *l=new QVBoxLayout();
    l->setMargin(0);
    l->setSpacing(0);
    l->addWidget(m_styledBar);
    l->addWidget(m_propertyView);

    this->setLayout(l);

    QLabel* label=new QLabel(tr("Object Property"));
    label->setStyleSheet("color:rgb(255,255,255);");
    QVBoxLayout *layout=new QVBoxLayout;
    layout->setMargin(5);
    layout->addWidget(label);
    m_styledBar->setLayout(layout);

    connect(m_propertyView,SIGNAL(need_make_page_position()),this,SIGNAL(need_make_page_position()));
}

void QPropertyView::selectWidget(QWidget *wid)
{
    if(m_select==wid)
    {
        return;
    }
    m_select=wid;
    if(wid==NULL)
    {
        m_propertyView->setPropertys(QList<SHAREDLIB::QAbstractProperty*>());
    }
    else
    {
        SHAREDLIB::QAbstractHost* host=(SHAREDLIB::QAbstractHost*)wid->property("host").toInt();
        if(host!=NULL)
        {
            m_propertyView->setPropertys(host->propertys());
        }
    }
}

void QPropertyView::page_position(QVariant &param)
{
    m_propertyView->page_position(param);
}

void QPropertyView::set_page_position(const QVariant &info)
{
    m_propertyView->set_page_position(info);
}

bool QPropertyView::pagePosition(const QVariant &param)
{
    return m_propertyView->pagePosition(param);
}
